<html>
	<head>
		<style type="text/css">
		    /* Prevent copy paste for all elements except text fields */

		    table tr td{
		    	border: 1px black solid;
		    }
		</style>
		<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> 
		<script type="text/javascript">
	    $(document).ready(function(){
	    	var varData="";
	        $.ajax({
	            type: "POST",
	            url: "http://localhost:8000/Uni/Project/Emailtest/requestList.php",
	            data: varData,
	            success: function(data){
	                //alert("complete userID=" + sessionStorage.userID);
	                $("#requests").html(data);
	            }
	        });

	        $('#submit').click(function(){
	            var username = $('#username').val();
	            var password = $('#password').val();
	            var varData = 'username=' + username + '&password=' + password;
	            console.log(varData);
	            $.ajax({
	                type: "POST",
	                url: "http://localhost:8000/Uni/Project/Emailtest/login.php",
	                data: varData,
	                success: function(data){
	                    if(IsNumeric(data)){
	                        console.log(data);
	                        sessionStorage.userID = data;
	                        sessionStorage.username = username;
	                        $("#user").html(sessionStorage.username);
	                        $("#login").remove();
	                    }
	                    else
	                    {
	                        console.log(data);
	                        $("h1").before(data);
	                    }
	                }
	            });
	        });
	        
	    });

		function IsNumeric(n) {
    		return !isNaN(parseFloat(n)) && isFinite(n);
		}

	</script>
	</head>
	<body>
		<h1>Administration<h1>
		<p id="user"></p>
		<div id="login">
			<h1>Login</h1>
	        <form>
	            <input type="text" name="username" id="username" />
	            <label for="username">Username</label>
	            <br>
	            <input type="password" name="password" id="password" />
	            <label for="password">Password</label>
	            <br>
	        </form>
	        <button id="submit">Click to submit</button>
		</div>
		<div id="requests"></div>
	</body>
</html>